package DD10;

import java.util.HashSet;

import org.junit.Test;

public class SetTest {

	public static void main(String[] args) {
		SetTest s = new SetTest();
		s.test1();
	}
	
	@Test
	public void test1() {
		HashSet set = new HashSet<>();
		Person p1 = new Person(1001,"AA");
		Person p2 = new Person(1002,"bb");
		set.add(p1);
		set.add(p2);
		System.out.println(set);
		p1.setName("CC");
		System.out.println(set);
		set.remove(p1);//this remove will check the hashcode of 1001 CC. So the position of it's probably changed.
		System.out.println(set);
		//So it won't remove success
		set.add(new Person(1001,"AA"));
		System.out.println(set);
	}
}
